package copyengine.network.roomStructure
{
	import copyengine.GameFacade;
	import copyengine.dataLayer.sync.CEDataLayerSyncCommandNotification;

	public final class CENetworkCommandUtils
	{
		public function CENetworkCommandUtils()
		{
		}

		/**
		 * 给房间上锁，同时尝试启动P2P加速
		 * 注意::!!! 只有房主才会真正发送Lock房间的Command,其他玩家只是开启P2P加速
		 */
		public static function lockRoom():void
		{
			GameFacade.instance.sendNotification(CENetworkCommandNotification.RECEIVE_COMMAND_LOCK_ROOM);
		}

		/**
		 * 给房间解锁，同时关闭P2P加速
		 * 注意::!!! 只有房主才会真正发送UnLock房间的Command,其他玩家只是关闭P2P加速
		 */
		public static function unlockRoom():void
		{
			GameFacade.instance.sendNotification(CENetworkCommandNotification.RECEIVE_COMMAND_UNLOCK_ROOM);
		}

		/**
		 * 在大厅中创建一个房间
		 */
		public static function createRoom(_roomName:String, _password:String, _playerUID:String):void
		{
			GameFacade.instance.sendNotification(CENetworkCommandNotification.RECEIVE_COMMAND_CREATE_ROOM,
												 {
													 roomName:_roomName,
													 roomPassword:_password,
													 playerUID:_playerUID
												 });
		}

		/**
		 * 加入一个房间
		 */
		public static function joinRoom(_roomID:int, _password:String, _playerUID:String):void
		{
			GameFacade.instance.sendNotification(CENetworkCommandNotification.RECEIVE_COMMAND_JOIN_ROOM,
												 {
													 roomID:_roomID,
													 roomPassword:_password,
													 playerUID:_playerUID
												 });
		}

		/**
		 * 离开一个房间
		 */
		public static function quitRoom():void
		{
			GameFacade.instance.sendNotification(CENetworkCommandNotification.RECEIVE_COMMAND_QUIT_ROOM, {});
		}

		/**
		 * 给在一组内的其他玩家同步发送Command
		 *
		 * @param _notificationName 发送的Notification Name
		 * @param _notificationArg  发送的Notification 参数
		 *
		 */
		public static function sendSyncCommand(_notificationName:String, _notificationArg:Object):void
		{
			GameFacade.instance.sendNotification(CEDataLayerSyncCommandNotification.RECEIVE_SEND_P2P_COMMAND_TO_OTHER,
												 {
													 notificationName:_notificationName,
													 notificationArg:_notificationArg
												 });
		}


	}
}
